function getIdtest(idSess){
	var ret = -1;
	$.each(sessionsDATA,function(key,session){
		if(session.idSession == idSess)
			ret = session.test.id;
	});
	return ret;
}

function buttonClickHandler(){
	var id = $(this).attr('id');
	var idSession = id.split('_')[1];
	var idTest = getIdtest(idSession);
	localStorage["idCurrentSession"] = idSession;
	localStorage["idCurrentTest"] = idTest;
	
	showTest();
}

function displaySessions(){
	$('#content').html("");
	$.each(sessionsDATA, function(key, session) {
		$('#content').append(sessionHTML);
		$('#tmp_button').attr('id', 'butt_' + session.idSession);
		$('#butt_' + session.idSession).click(buttonClickHandler);
		$('#content article:last-child').attr('id', 'session_' + session.idSession);
		$('#session_' + session.idSession + ' .session_title').html(session.test.name);
		$('#session_' + session.idSession + ' .session_exp_date').html(session.dateFin);
		$('#session_' + session.idSession + ' .session_max_duration').html(session.test.time);
		$('#session_' + session.idSession + ' .session_nb_questions').html(session.test.nbQuestions);
	});
}